import React, { useEffect } from 'react'
import { Divider, Button, TextArea, Dialog, Toast } from 'antd-mobile'


import { getCaseDetails } from '../../axiosRequest/api.js'


//函数
function Handle() {
    /**
     * useState 后面的参数是初始化值 任意类型
     * setCount 更改属性的方法
     */
    // const [] = useState()


    //[]空数组相当于componentDidMount
    useEffect(() => {

        //返回的函数相当于unmountComponentAtNode
        return () => {

        }
    }, []);


    function clickHandle() {
        Dialog.confirm({
            content: '是否确认上报案件', onConfirm: () => {
                handle();
            }
        })
    }

    function handle() {

        //模拟请求接口
        const paramObj3 = {
            taskNum: "202207290045",
        }
        getCaseDetails(paramObj3)
            .then(response => {
                const data = response.data.data
                console.log('getCaseDetails>', data);
                Toast.show({ icon: 'success', content: '上报成功' })
            })
            .catch(error => {
                console.log('getCaseDetails-error>', error);
                Toast.show({ icon: 'fail', content: '上报失败' })
                console.log(error);
            });
    }


    return (<div className={handle.container}>
        <TextArea style={{ '--font-size': '15px' }} placeholder='请输入问题描述...' showCount maxLength={120} rows={5} />
        <Divider></Divider>
        <Button block color='primary' size='large' onClick={clickHandle}>确认上报</Button>
    </div>)
}


export default Handle

